#ifndef DEFECTDATATCPCLIENT_H
#define DEFECTDATATCPCLIENT_H

#include <QObject>
#include <QTimer>
#include <QTcpSocket>
class DefectDataTcpClient : public QObject
{
    Q_OBJECT
public:
    explicit DefectDataTcpClient(QObject *parent = nullptr);

public:
    void  tryConnect();
    void onConnected();
    void onDisConnected();

    void startConnection(const QString &host, quint16 port);

    QString ConvertJsonToStr(const QJsonObject &jsonObject);
    void SendData(const QJsonObject &jsonObject );


signals:

private:
    QTcpSocket *socket;
    QTimer *reconnectTimer;
    QString host;
    quint16 port;
    int retryCount;
    const int maxRetry;
};

#endif // DEFECTDATATCPCLIENT_H
